package com.itlong.cloud.property.resource;

import com.itlong.cloud.POJO.DTO.property.PropertyPadListDTO;
import com.itlong.cloud.POJO.VO.property.PropertyPadGetOneVO;
import com.itlong.cloud.POJO.VO.property.PropertyPadListVO;
import com.itlong.cloud.equip.property.IPropertyPadServiceClient;
import com.itlong.cloud.property.service.IPropertyPadService;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * <desc>
 *      物业平板业务交互暴露接口实现类
 * </desc>
 *
 * @createDate 2019/01/17
 */
@RestController
public class IPropertyPadServiceResource implements IPropertyPadServiceClient {
    @Autowired
    IPropertyPadService iPropertyPadService;

    /**
     * <desc>
     *      获取人脸平板列表
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2019/01/17
     */
    @PostMapping("/property/equip/pad/getList")
    @Override
    public Page<PropertyPadListVO> getList(@RequestBody PropertyPadListDTO dto) throws Exception{
        return iPropertyPadService.getList(dto);
    }

    /**
     * <desc>
     *      删除设备
     * </desc>
     *
     * @param deviceUnique
     * @return
     * @author Jiaqi.X
     * @createDate 2019/01/17
     */
    @PostMapping("/property/equip/pad/delete")
    public Integer delete(@RequestParam("deviceUnique") String deviceUnique) throws Exception {
        return iPropertyPadService.delete(deviceUnique);
    }

    /**
     * <desc>
     *      获取单个平板信息
     * </desc>
     *
     * @param deviceUnique
     * @return
     * @author Jiaqi.X
     * @createDate 2019/01/17
     */
    @PostMapping("/property/equip/pad/getOne")
    public PropertyPadGetOneVO getOne(@RequestParam("deviceUnique") String deviceUnique) throws Exception{
        return iPropertyPadService.getOne(deviceUnique);
    }

    /**
     * <desc>
     *     添加平板信息
     * </desc>
     *
     * @param vo
     * @return
     * @author Jiaqi.X
     * @createDate 2019/01/17
     */
    @PostMapping("/property/equip/pad/add")
    public String add(@RequestBody PropertyPadGetOneVO vo) throws Exception{
        return iPropertyPadService.add(vo);
    }

    /**
     * <desc>
     *      修改平板
     * </desc>
     *
     * @param vo
     * @return
     * @author Jiaqi.X
     * @createDate 2019/01/17
     */
    @PostMapping("/property/equip/pad/update")
    public String update(@RequestBody PropertyPadGetOneVO vo) throws Exception{
        return iPropertyPadService.update(vo);
    }

    /**
     * <desc>
     *     添加时检测机号是否重复
     * </desc>
     *
     * @param projectId
     * @param deviceId
     * @return
     * @author Jiaqi.X
     * @createDate 2019/01/17
     */
    @PostMapping("/property/equip/pad/checkPadDeviceRepeat")
    public Integer checkPadDeviceRepeat(@RequestParam("projectId") String projectId,
                                        @RequestParam("deviceId") String deviceId,
                                        @RequestParam("type") Integer type){
        return iPropertyPadService.checkPadDeviceRepeat(projectId,deviceId,type);
    }

    /**
     * <desc>
     *      根据deviceUnique找出绑定该设备的平板设备
     * </desc>
     *
     * @param deviceUnique
     * @return
     * @Author Zhu.yj
     * @createDate  2019/12/17
     */
    @PostMapping("/property/equip/pad/getPadDeviceUniqueByBindDevice")
    @Override
    public List<String> getPadDeviceUniqueByBindDevice(@RequestParam("deviceUnique") String deviceUnique) throws Exception {
        return iPropertyPadService.getPadDeviceUniqueByBindDevice(deviceUnique);
    }

    /**
     * <desc>
     *      更新平板地址
     * </desc>
     *
     * @param newUnitIdStr 要添加的单元集合
     * @param deviceUnique 设备编号
     * @param padDeviceUniqueList 平板设备编号
     * @param projectId 项目id
     * @return
     * @Author Zhu.yj
     * @createDate  2019/12/18
     */
    @Override
    @PostMapping("/property/equip/pad/updatePadAddress")
    public Integer updatePadAddress(@RequestParam("newUnitIdStr") String newUnitIdStr,
                                    @RequestParam("deviceUnique") String deviceUnique,
                                    @RequestBody List<String> padDeviceUniqueList,
                                    @RequestParam("projectId") String projectId) throws Exception {
        return iPropertyPadService.updatePadAddress(newUnitIdStr,deviceUnique,padDeviceUniqueList,projectId);
    }


}
